package com.itheima.atomic;

import java.util.concurrent.atomic.AtomicInteger;

public class Demo03 {

    public static void main(String[] args) {
        AtomicInteger ac1 = new AtomicInteger();
        AtomicInteger ac2 = new AtomicInteger(10);
        System.out.println(ac1.getAndIncrement());
        //ac1加(ac2自加)//
        System.out.println(ac1.getAndAdd(ac2.incrementAndGet()));//1
        System.out.println(ac1.get());//12
        ac1.compareAndSet(11,1);
        ac1.compareAndSet(12,2);
        int result1 = ac1.get();
        int result2 = ac2.get();
        System.out.println(result1);//2
        System.out.println(result2);//11

    }
}
